<template>
    <Form class="login" ref="formInline" :model="formInline" :rules="ruleInline" inline>
        <FormItem prop="user">
            <Input type="text" v-model="formInline.user" placeholder="Username"/>
        </FormItem>
        <br>
        <FormItem prop="password">
            <Input type="password" v-model="formInline.password" placeholder="Password"/>
        </FormItem>
        <br>
        <FormItem>
            <Button  type="primary" @click="handleSubmit('formInline')">
                登录
            </Button>
        </FormItem>
    </Form>

</template>

<script>
    export default {
        name: "LoginForm",
        data() {
            return {
                formInline: {
                    user: '',
                    password: ''
                },
                ruleInline: {
                    user: [
                        {required: true, message: '请填写用户名', trigger: 'blur'}
                    ],
                    password: [
                        {required: true, message: '请填写密码', trigger: 'blur'},
                        {type: 'string', min: 6, message: '密码长度不能小于6位', trigger: 'blur'}
                    ]
                }
            }
        },
        methods: {
            handleSubmit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.$Message.success('提交成功!')
                    } else {
                        this.$Message.error('表单验证失败!')
                    }
                })
            }
        }

    }
</script>

<style scoped>
.login{
    margin: 0 auto;
    /*width: 1250px;*/
}
</style>